package cn.tedu.rabbitmqboot.m3;


import org.springframework.amqp.core.FanoutExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public FanoutExchange logsExchange() {
        // true : 持久队列
        // Fanout 交换机: 群发消息
        return new FanoutExchange("logs", false, false); // 第二个参数:非持久 3:不自动删除
    }

    @Autowired
    private Producer producer;

    @PostConstruct
    public void test() {
        new Thread(() -> producer.send()).start();  //lambda 表达式
    }
}
